#pragma once
using namespace Ogre;
class CBaseMatFactory;
class matUiEditor;
#define  MAXPATHNUM 1024



class BaseMat
{
public:
	BaseMat(const Ogre::String & matName,matUiEditor * pMat);
	~BaseMat(void);
	virtual const Ogre::String  getName();
	virtual void                connect(Ogre::SubEntity * ent);   //
	virtual void                desConnect(Ogre::SubEntity  * ent);//
	void                       exportMat(const Ogre::String& path);
	static CBaseMatFactory *    getFactory();

	MaterialPtr                 getMatP(){return m_MaterialPtr;}
	void                        getMatBuffer(Ogre::String & maxSrc);
	virtual  void               init(const Ogre::String & matName){};
	virtual  void               loadMaxXml(Ogre::String &strloadMaxXml, Ogre::String &strMatBuffer);
	void                        ExportMaxXml(Ogre::String &buffer);

	virtual void                 CopyTextureFile(Ogre::String &maxPath);


	Ogre::String      m_tempmatName;
	Ogre::String      m_MatName;
	MaterialPtr       m_MaterialPtr;
protected:



	matUiEditor *       m_pmatEditor;

protected:

};

typedef std::vector<BaseMat *> VMATLIST; 
typedef std::map<Ogre::String,BaseMat *> MATLIST; 

class   CBaseMatFactory
{
public:
	int m_InstanceCount;
	CBaseMatFactory() {m_InstanceCount = 0;};
	virtual ~CBaseMatFactory() {};
	virtual BaseMat *CreateObject(Ogre::NameValuePairList &params,matUiEditor * pMat);

	virtual void DestroyObject(BaseMat *object);
	virtual bool CanInstantiate() {return true;};
};

typedef std::map<Ogre::String,CBaseMatFactory *> FactoryMAT; 
